/**
 * file have save file Dialog & filter for opening only xml files 
 */
package com.keggview.application.actions;

import org.eclipse.jface.action.Action;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.FileDialog;
import org.eclipse.ui.IWorkbenchWindow;


public class SaveFileAction extends Action {

	private IWorkbenchWindow window;
	
	public static final String ID = "com.keggview.application.actions.SaveFileAction";
	
	public SaveFileAction(IWorkbenchWindow window) {
		String description = "Zapisuje plik mapy z bazy Kegg";
		this.window = window;
		this.setId(SaveFileAction.ID);
		this.setText("Zapisz\tCtrl+S");
		this.setToolTipText(description);
		this.setAccelerator(SWT.CTRL + 'S');
	}
	
	@Override
	public void run() {
		FileDialog fd = new FileDialog(window.getShell(), SWT.SAVE);
		String[] fNames = {"Mapy XML"};
		String[] fExt	= {"*.xml"};
		fd.setFilterNames(fNames);
		fd.setFilterExtensions(fExt);
		fd.setText("Zapisz mapę typu XML z bazy Kegg");
		fd.open();
	}

}
